<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>六边形</title>
</head>

<body>
    <!--
        作者：放弃懒惰
        链接：https://www.zhihu.com/question/40149352/answer/3123033666
        来源：知乎
        著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。
    -->
    <div class="hexagon"></div>
    <style>
        .hexagon {
            position: relative;
            display: block;
            width: 100px;
            height: 55px;
            background-color: rgb(235, 135, 205);

            margin: 2em;
        }

        .hexagon:before {
            position: absolute;
            top: -25px;
            left: 0;
            width: 0;
            height: 0;
            content: "";
            border-right: 50px solid transparent;
            border-bottom: 25px solid rgb(235, 135, 205);
            border-left: 50px solid transparent;
        }

        .hexagon:after {
            position: absolute;
            bottom: -25px;
            left: 0;
            width: 0;
            height: 0;
            content: "";
            border-top: 25px solid rgb(235, 135, 205);
            border-right: 50px solid transparent;
            border-left: 50px solid transparent;
        }
    </style>
</body>

</html>